package com.carepad.action;

import org.apache.struts2.ServletActionContext;

import com.carepad.util.Pager;

public class AbstractManagementAction extends AbstractAction {

	private static final long serialVersionUID = 1L;
	
	public enum Mode {ADD, EDIT}
	
	protected Integer uid;
	protected Mode mode = Mode.ADD;  //default
	protected Pager pager;
	protected Integer pageStart = Pager.DEFAULT_PAGE_START;
	protected Integer pageSize = Pager.DEFAULT_PAGE_SIZE;
	protected int numberOfSubItemsInList = 3;

	public Mode getMode() {
		return mode;
	}

	public void setMode(Mode mode) {
		this.mode = mode;
	}

	public Integer getId() {
		return uid;
	}

	public void setId(Integer uid) {
		this.uid = uid;
	}

	public Pager getPager() {
		return pager;
	}

	public void setPager(Pager pager) {
		this.pager = pager;
	}

	public Integer getPageStart() {
		return pageStart;
	}

	public void setPageStart(Integer pageStart) {
		this.pageStart = pageStart;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	
	public int getNumberOfSubItemsInList() {
		return numberOfSubItemsInList;
	}

	public void setNumberOfSubItemsInList(int numberOfSubItemsInList) {
		this.numberOfSubItemsInList = numberOfSubItemsInList;
	}

	public Pager setActionContext(Pager pager) {
		pager.setActionCallInfo(ServletActionContext.getActionMapping().getName(), 
				ServletActionContext.getActionMapping().getNamespace(),
				ServletActionContext.getRequest().getParameterMap());
		
		return pager;
	}
	
}
